package adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.gongxiangcheng.R;

import java.util.List;

/**
 * Created by Administrator on 2017/3/16.
 */

public class RecyAdapter extends RecyclerView.Adapter<RecyAdapter.ViewHolder> {

    private List<String> mDataSet;

    //构造器，接受数据集
    public RecyAdapter(List<String> data){
        mDataSet = data;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //加载布局文件
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rc_mine,parent,false);
        ViewHolder vh = new ViewHolder(v);
        return vh;

    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        //将数据填充到具体的view中
       //holder.textView.setText(mDataSet.get(position));
    }


    @Override
    public int getItemCount() {
        return mDataSet.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
         //private TextView textView;

        public ViewHolder(View itemView) {super(itemView);
            //由于itemView是item的布局文件，我们需要的是里面的textView，因此利用itemView.findViewById获
            //取里面的textView实例，后面通过onBindViewHolder方法能直接填充数据到每一个textView了



        }
    }
}
